{
  "properties" : { },
  "id" : "50862b3e6294461da5053cad5889821f",
  "script" : null,
  "groupId" : "b6f6fb0fd52346bab5c701818bbf14f7",
  "name" : "统计设备日志条数",
  "createTime" : 1727071120953,
  "updateTime" : 1726299906815,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "queryStatistics",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"weekCounts\": 0,\n        \"monthCounts\": 0,\n        \"yearCounts\": 2,\n        \"dayCounts\": 0\n    }\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : "",
    "value" : { },
    "description" : "",
    "required" : false,
    "dataType" : "String",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ ]
  },
  "responseBodyDefinition" : {
    "name" : "",
    "value" : "",
    "description" : "",
    "required" : false,
    "dataType" : "Object",
    "type" : "",
    "defaultValue" : "",
    "validateType" : "",
    "error" : "",
    "expression" : "",
    "children" : [ {
      "name" : "status",
      "value" : "200",
      "description" : "",
      "required" : false,
      "dataType" : "Integer",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "message",
      "value" : "success",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    }, {
      "name" : "data",
      "value" : "0",
      "description" : "",
      "required" : false,
      "dataType" : "String",
      "type" : "",
      "defaultValue" : "",
      "validateType" : "",
      "error" : "",
      "expression" : "",
      "children" : [ ]
    } ]
  }
}
================================
import java.time.LocalDateTime

var weekStartTime = DateUtil.getTimesWeekmorning();
var weekEndTime = DateUtil.getTimesWeeknight();
var sql = """
  select
        count(1)
        from
        ndmp_syslog_dc o
        where
        1=1
        <if test="weekStartTime != null and weekStartTime !='' ">
            AND o.create_time   >= to_timestamp(#{weekStartTime},'yyyy-mm-dd hh24:mi:ss')  
        </if>
        <if test="weekEndTime != null and weekEndTime !='' " >
            AND o.create_time   <=  to_timestamp(#{weekEndTime},'yyyy-mm-dd hh24:mi:ss') 
        </if>

"""
var week = db.selectValue(sql)::long

var monthStartTime = DateUtil.getTimesMonthmorning();
var monthEndTime = DateUtil.getTimesMonthnight();
var sql = """
  select
        count(1)
        from
        ndmp_syslog_dc o
        where
        1=1
        <if test="monthStartTime != null and monthStartTime !='' ">
            AND o.create_time   >= to_timestamp(#{monthStartTime},'yyyy-mm-dd hh24:mi:ss')  
        </if>
        <if test="monthEndTime != null and monthEndTime !='' " >
            AND o.create_time   <=  to_timestamp(#{monthEndTime},'yyyy-mm-dd hh24:mi:ss') 
        </if>

"""
var month = db.selectValue(sql)::long

var yearStartTime = DateUtil.getTimesYearmorning();
var yearEndTime = DateUtil.getTimesYearnight();
var sql = """
  select
        count(1)
        from
        ndmp_syslog_dc o
        where
        1=1
        <if test="yearStartTime != null and yearStartTime !='' ">
            AND o.create_time   >= to_timestamp(#{yearStartTime},'yyyy-mm-dd hh24:mi:ss')  
        </if>
        <if test="yearEndTime != null and yearEndTime !='' " >
            AND o.create_time   <=  to_timestamp(#{yearEndTime},'yyyy-mm-dd hh24:mi:ss') 
        </if>

"""
var year = db.selectValue(sql)::long

var dayStartTime = DateUtil.getTimesDaymorning();
var dayEndTime = DateUtil.getTimesDaynight();
var sql = """
  select
        count(1)
        from
        ndmp_syslog_dc o
        where
        1=1
        <if test="dayStartTime != null and dayStartTime !='' ">
            AND o.create_time   >= to_timestamp(#{dayStartTime},'yyyy-mm-dd hh24:mi:ss')  
        </if>
        <if test="dayEndTime != null and dayEndTime !='' " >
            AND o.create_time   <=  to_timestamp(#{dayEndTime},'yyyy-mm-dd hh24:mi:ss') 
        </if>

"""
var day = db.selectValue(sql)::long
var res = {
    "weekCounts": week,
    "monthCounts": month,
    "yearCounts": year,
    "dayCounts": day
}
return res;